home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / M2Crypto / PGP / PublicKey.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  64 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from constants import *
  5. from packet import *
  6. import RSA
  7.  
  8. class PublicKey:
  9.     
  10.     def __init__(self, pubkey_pkt):
  11.         self._pubkey_pkt = pubkey_pkt
  12.         self._pubkey = RSA.new_pub_key((pubkey_pkt._e, pubkey_pkt._n))
  13.         self._userid = { }
  14.         self._signature = { }
  15.  
  16.     
  17.     def keyid(self):
  18.         return self._pubkey.n[-8:]
  19.  
  20.     
  21.     def add_userid(self, u_pkt):
  22.         self._userid[u_pkt.userid()] = u_pkt
  23.  
  24.     
  25.     def remove_userid(self, userid):
  26.         del self._userid[userid]
  27.  
  28.     
  29.     def add_signature(self, userid, s_pkt):
  30.         if self._signature.has_key(userid):
  31.             self._signature.append(s_pkt)
  32.         else:
  33.             self._signature = [
  34.                 s_pkt]
  35.  
  36.     
  37.     def __getitem__(self, id):
  38.         return self._userid[id]
  39.  
  40.     
  41.     def __setitem__(self, *args):
  42.         raise NotImplementedError
  43.  
  44.     
  45.     def __delitem__(self, id):
  46.         del self._userid[id]
  47.         if self._signature[id]:
  48.             del self._signature[id]
  49.         
  50.  
  51.     
  52.     def write(self, stream):
  53.         pass
  54.  
  55.     
  56.     def encrypt(self, ptxt):
  57.         return self._pubkey.public_encrypt(ptxt, RSA.pkcs1_padding)
  58.  
  59.     
  60.     def decrypt(self, ctxt):
  61.         return self._pubkey.public_encrypt(ctxt, RSA.pkcs1_padding)
  62.  
  63.  
  64.